home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
graphics
/
chs_ultd.lzh
/
CHS_ULTD.500
/
SOURCE
/
FEIGBAUM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-25
|
22KB
|
704 lines
#include "..\xcommon.h"
#include "..\chs_ultd\feigenbm.h"
#include <math.h>
#include <tos.h>
#include <string.h>
int errno; /* damit der linker nicht motzt;
sonst in pc_start deklariert */
extern XCHAOS xfch; /* die definition kommt weiter unten */
int fgbm_nr; /* nummer der routine in chaos */
COMMON *common; /* zeiger für die routinen von chaos */
/*------------------------------------------------------------------------------
initialisierungsroutine,
muß nach linken am anfang des text-segmentes stehen,
d.h. im quelltext ganz vorne
------------------------------------------------------------------------------*/
XCHAOS *ret_chaos(COMMON *com)
{
common=com; /* merke com */
return &xfch; /* gib eigene routinen zurück */
}
/*------------------------------------------------------------------------------
parameterstrukturen
------------------------------------------------------------------------------*/
/*
bildparameter
*/
typedef struct
{
int flag; /* 0 quer, 1 hoch */
int n1; /* iterationen vor plot */
int n2; /* iterationen für plot */
int dn; /* iterationen zwischen zwei plot's */
long time; /* rechenzeit */
double r_min; /* definition des rechteckes */
double r_max;
double y_min;
double y_max;
double y0; /* startwert für iteration */
} FEIGENBAUM;
/*
bild(er)parameter für neu bilder
*/
typedef struct
{
FEIGENBAUM start; /* parameter des ersten bildes */
FEIGENBAUM end; /* parameter des letzten bildes */
int change[8]; /* interpolationstypen */
FEIGENBAUM act; /* speicherplatz für parameter des aktuellen bildes */
} FGBM_PAR;
/*
einstellungen
*/
typedef struct
{
int set;
FEIGENBAUM start;
FEIGENBAUM end;
int change[8];
int size;
int anzahl;
int color;
char name[10];
} FGBM_SET;
/*------------------------------------------------------------------------------
globale variable
------------------------------------------------------------------------------*/
static OBJECT *fg_par_ad,*fg_show_ad,*icons; /* dialogboxen */
FGBM_SET fgbm_set; /* einstellungen */
/*------------------------------------------------------------------------------
parameter einlesen
------------------------------------------------------------------------------*/
/*
schreibe standartvoreinstellungen nach set
*/
static void def_fgparam(FGBM_SET *set)
{
int i;
static FEIGENBAUM def_start={0,100,100,1,0l,
2.0,4.0,0.0,1.0,0.5};
set->start=def_start;
set->end=def_start;
for ( i=0; i<8; i++ )
set->change[i]=1;
set->anzahl=1; /* 1 bild */
set->size=S_BIG; /* große bilder */
set->color=0; /* normal */
strcpy(set->name,"FGBAUM");
}
/*
indizes der dialogbox-elemente
*/
/* interpolations-typen */
static char *ch_txt[]={"-","0","+"};
/* button für interpolation */
static int fb_ch[]={FB_RMIN,FB_RMAX,FB_XMIN,FB_XMAX,FB_X0,FB_N1,FB_N2,FB_DN};
/* tedinfo's der start-parameter */
static int fb_1[]={FB_RMIN1,FB_RMAX1,FB_XMIN1,FB_XMAX1,FB_X0_1,FB_N1_1,FB_N2_1,FB_DN_1};
/* tedinfo's der end-parameter */
static int fb_2[]={FB_RMIN2,FB_RMAX2,FB_XMIN2,FB_XMAX2,FB_X0_2,FB_N1_2,FB_N2_2,FB_DN_2};
/*
belege dialogbox vor
*/
static void set_fgparam(FGBM_SET *set,FGBM_PAR *fgbm)
{
int i;
if ( !set->set ) /* keine einstellungen? -> standartvoreinstellungen */
def_fgparam(set);
strcpy(objc_tedstr(fg_par_ad,FB_NAME),set->name); /* objektname */
common->sprintf(objc_tedstr(fg_par_ad,FB_ANZ),"%4d",set->anzahl); /* anzahl */
objc_unselect(fg_par_ad,FB_SMALL); /* größe */
objc_unselect(fg_par_ad,FB_MED);
objc_unselect(fg_par_ad,FB_BIG);
objc_select(fg_par_ad,FB_SMALL+set->size);
/* parameter links */
common->write_dbl(objc_tedstr(fg_par_ad,FB_RMIN1),set->start.r_min,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_RMAX1),set->start.r_max,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_XMIN1),set->start.y_min,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_XMAX1),set->start.y_max,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_X0_1),set->start.y0,15,11);
common->sprintf(objc_tedstr(fg_par_ad,FB_N1_1),"%4d",set->start.n1);
common->sprintf(objc_tedstr(fg_par_ad,FB_N2_1),"%4d",set->start.n2);
common->sprintf(objc_tedstr(fg_par_ad,FB_DN_1),"%3d",set->start.dn);
/* parameter rechts */
common->write_dbl(objc_tedstr(fg_par_ad,FB_RMIN2),set->end.r_min,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_RMAX2),set->end.r_max,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_XMIN2),set->end.y_min,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_XMAX2),set->end.y_max,15,11);
common->write_dbl(objc_tedstr(fg_par_ad,FB_X0_2),set->end.y0,15,11);
common->sprintf(objc_tedstr(fg_par_ad,FB_N1_2),"%4d",set->end.n1);
common->sprintf(objc_tedstr(fg_par_ad,FB_N2_2),"%4d",set->end.n2);
common->sprintf(objc_tedstr(fg_par_ad,FB_DN_2),"%3d",set->end.dn);
/* interpolationstypen */
for( i=0; i<8; i++ ) {
objc_spec(fg_par_ad,fb_ch[i])=ch_txt[set->change[i]];
fgbm->change[i]=set->change[i];
}
/* bildtyp: normal/quer */
objc_select(fg_par_ad,FB_NRM+set->start.flag);
objc_unselect(fg_par_ad,FB_QUR-set->start.flag);
/* darstellung (normal/invers) */
objc_unselect(fg_par_ad,FB_INV+set->color);
objc_select(fg_par_ad,FB_NORM-set->color);
}
/*
parameter aus dialogbox auslesen
*/
static int get_fgparam(FGBM_PAR *param,X_PARAM *x_param)
{
x_param->xor_offset=0; /* kein xor offset, xor bringt eh nichts */
strcpy(x_param->name,objc_tedstr(fg_par_ad,FB_NAME)); /* name */
common->sscanf(objc_tedstr(fg_par_ad,FB_ANZ),"%d",&x_param->anzahl);/* anzahl */
if ( objc_selected(fg_par_ad,FB_SMALL) ) /* größe */
x_param->size=S_SMALL;
else if ( objc_selected(fg_par_ad,FB_MED) )
x_param->size=S_MID;
else
x_param->size=S_BIG;
/* startparameter */
common->sscanf(objc_tedstr(fg_par_ad,FB_RMIN1),"%lf",¶m->start.r_min);
common->sscanf(objc_tedstr(fg_par_ad,FB_RMAX1),"%lf",¶m->start.r_max);
if ( param->start.r_min>param->start.r_max )
return FB_RMIN1;
common->sscanf(objc_tedstr(fg_par_ad,FB_XMIN1),"%lf",¶m->start.y_min);
common->sscanf(objc_tedstr(fg_par_ad,FB_XMAX1),"%lf",¶m->start.y_max);
if ( param->start.y_min>param->start.y_max )
return FB_XMIN1;
common->sscanf(objc_tedstr(fg_par_ad,FB_X0_1),"%lf",¶m->start.y0);
common->sscanf(objc_tedstr(fg_par_ad,FB_N1_1),"%d",¶m->start.n1);
common->sscanf(objc_tedstr(fg_par_ad,FB_N2_1),"%d",¶m->start.n2);
common->sscanf(objc_tedstr(fg_par_ad,FB_DN_1),"%d",¶m->start.dn);
/* endparameter */
common->sscanf(objc_tedstr(fg_par_ad,FB_RMIN2),"%lf",¶m->end.r_min);
common->sscanf(objc_tedstr(fg_par_ad,FB_RMAX2),"%lf",¶m->end.r_max);
if ( x_param->anzahl>1 && param->end.r_min>param->end.r_max )
return FB_RMIN2;
common->sscanf(objc_tedstr(fg_par_ad,FB_XMIN2),"%lf",¶m->end.y_min);
common->sscanf(objc_tedstr(fg_par_ad,FB_XMAX2),"%lf",¶m->end.y_max);
if ( x_param->anzahl>1 && param->end.y_min>param->end.y_max )
return FB_XMIN2;
common->sscanf(objc_tedstr(fg_par_ad,FB_X0_2),"%lf",¶m->end.y0);
common->sscanf(objc_tedstr(fg_par_ad,FB_N1_2),"%d",¶m->end.n1);
common->sscanf(objc_tedstr(fg_par_ad,FB_N2_2),"%d",¶m->end.n2);
common->sscanf(objc_tedstr(fg_par_ad,FB_DN_2),"%d",¶m->end.dn);
/* interpolationstypen stehen schon in param->change[] ! */
if ( objc_selected(fg_par_ad,FB_QUR) ) /* bildtyp */
param->start.flag=1;
else
param->start.flag=0;
if ( objc_selected(fg_par_ad,FB_INV) ) /* farbe */
x_param->color=1;
else
x_param->color=0;
param->start.time=0l; /* zeit auf null setzen */
return 0;
}
/*
parameter / block aus objekt
*/
int get_fgbm_objc(int side)
/* side FB_GET1 = linke, FB_GET2 = rechte parameterspalte */
/* FB_BLK1, FB_BLK2 -> block */
{
int *objcs;
FR_OBJC *object;
FEIGENBAUM *fgbm;
double x_min,x_max,y_min,y_max;
if ( side==FB_GET1 |